﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _68抽象类
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            Animal a1 = new Dog();
            a1.Say();//旺旺

            Animal a2 = new Cat();
            a2.Say();//喵喵
        }
    }

    internal abstract class Animal//1.抽象类可以包含普通成员,2.不能创建对象
    {
        public int age;
        public abstract void Say();//1.抽象方法没有方法体,2必须包含在抽象类中,3子类必须重写除非子类也抽象
    }

    internal class Dog : Animal
    {
        public override void Say()
        {
            Console.WriteLine("旺旺");
        }
    }
    internal class Cat : Animal
    {
        public override void Say()
        {
            Console.WriteLine("喵喵");
        }
    }
}

//练习  父类A包含一个抽象方法Fun,子类B重写Fun输出"X",子类C重写Fun输出Y